/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package business;

import dal.TourBookingDAL;
import java.util.ArrayList;
import java.util.List;
import model.TourBooking;

/**
 *
 * @author Nhang Con
 */
public class TourBookingBusiness {

    private TourBookingDAL tourBookDAl = new TourBookingDAL();

    public List<TourBooking> getListTourBooking(int pageID) {
        List<TourBooking> ltour=tourBookDAl.getListTourBooking();
         List<TourBooking> listTourByPage = new ArrayList<TourBooking>();
        for (int i = (pageID - 1) * 3; i < (pageID * 3); i++) {
            try {
                listTourByPage.add(ltour.get(i));
            } catch (IndexOutOfBoundsException e) {
                return listTourByPage;
            }
        }
        return listTourByPage;

           }

     public int getRowInListTour() {
        return tourBookDAl.getListTourBooking().size();
    }

    public String getUserNameFromID(int iduser) {
        return tourBookDAl.getUserName(iduser);

    }

    public String getPackageNameFromID(int idpakagetour) {


        return tourBookDAl.getPackageName(idpakagetour);

    }
    private BankBusiness bankbusiness = new BankBusiness();

    public boolean updateStatusBooking(int pktourid, int tourbookingid, int status, int idcustomer) {
        if (tourBookDAl.updateStatusTourBookigng(tourbookingid, status)) {
            bankbusiness.reFundsTour(pktourid, tourbookingid, idcustomer);
            return true;
        }
        return false;
    }
    public List<TourBooking> getListSearchByUser(String username){

    return tourBookDAl.getSearchTourBookingByUser(username);

    }
}
